const knex = require('./conn');
const bcrypt = require('bcrypt');

async function addUser({mail, pass}) {

  const hashed = bcrypt.hashSync(pass, bcrypt.genSaltSync(4));

  return knex('user-account')
  .insert({mail, pass: hashed})
  .returning('*');
}

async function findOneUser({mail}) {

  return knex('user-account').where({ mail }).first()

}

module.exports = {
  addUser,
  findOneUser,
};